package com.anosine.gpsl.android.ui.activity;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageView;
import android.widget.TextView;

import com.anosine.gpsl.android.R;
import com.anosine.gpsl.android.presenter.BasePresenterActivity;
import com.anosine.gpsl.android.presenter.RegAgreementPresenter;
import com.anosine.gpsl.android.presenter.RegisterPresenter;
import com.anosine.gpsl.android.ui.RegAgreementView;
import com.anosine.gpsl.android.ui.RegisterView;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.lidroid.xutils.view.annotation.event.OnClick;

public class RegAgreementActivity extends BasePresenterActivity implements
		RegAgreementView {
	@ViewInject(R.id.content_tv_title)
	TextView title;
	@ViewInject(R.id.webView)
	WebView webView;
	/**
	 * @Title: BackOnClick(View v)
	 * @Description: 返回按钮的点击事件，点击关闭当前activity
	 * @param: View v
	 * @return: 无
	 * @throws
	 */
	@OnClick(R.id.button_left)
	private void BackOnClick(View v) {
		finish();
	}

	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_register_agreement_layout);
		ViewUtils.inject(this);
		title.setText("注册协议");
		// 启动MVP
		//initActivityOfRegAgreement();

	}

	private void initActivityOfRegAgreement() {
		// 将合成的URL传给服务器
		RegAgreementPresenter presenter = new RegAgreementPresenter(this);
		presenter.loadRegAgreement();
	}

	@Override
	public void setRegAgreement(String url) {
		webView.getSettings().setJavaScriptEnabled(true);
		webView.loadUrl(url);
		webView.setWebViewClient(new WebViewClient() {
			@Override
			public boolean shouldOverrideUrlLoading(WebView view,
					String url) {
				view.loadUrl(url);
				return true;
			}
		});
	}

}
